<html>
 <head>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
     <script type="text/Javascript">
    $(document).ready(function(){ 
	  
              $("#r_button").click(function() {	
				   $(".error").hide();
				   $(".common").css("background", "#FFFFFF");
				});
           $("#s_button").click(function() {
                $(".error").hide();
                var stuname=$("#stuname").val();
                var cnumber=$("#cnumber").val();
				var emailid=$("#emailid").val();
				var address=$("#address").val();
				var course=$("#course").val();
				var password=$("#password").val();
				var courseid=$("#course_combo").val();
				 
				 if(stuname=="")
			          {
                      $("#stuname").css("background", "#DB5C04");
					  $("#stuname").focus();
					  return false;
			          }
					  else{
						  $("#stuname").css("background", "#FFFFFF");
						  }
					  if(cnumber=="")
			          {
                      $("#cnumber").css("background", "#DB5C04");
					  $("#cnumber").focus();
					  return false;
			          }else{
						  $("#cnumber").css("background", "#FFFFFF");
						  }
                    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; 
      
                     if(emailid=="")
			          {
                      $("#emailid").css("background", "#DB5C04");
					  $("#emailid").focus();
					  return false;
			          }
                         else if(!emailPattern.test(emailid)){  
       
                          $("#emailError").show();
                           $("#emailid").css("background", "#DB5C04");
					      $("#emailid").focus();
                           return false;
                              }else{
						  $("#emailid").css("background", "#FFFFFF");
						  }
                if(course=="")
			          {
                      $("#course").css("background", "#DB5C04");
					  $("#course").focus();
					  return false;
			          }else{
						  $("#course").css("background", "#FFFFFF");
						  }

						  if(courseid=="-1")
			             {
				      $("#courseError").show();
                      $("#course_combo").css("background", "#DB5C04");
					  $("#course_combo").focus();

					  return false;
			              }else{
						  $("#course_combo").css("background", "#FFFFFF");
						  }

						   if(password=="")
			             {
                      $("#password").css("background", "#DB5C04");
					  $("#password").focus();
					  return false;
			              }else{
						  $("#password").css("background", "#FFFFFF");
						  }


	      

               });  
				 	  
	      
           });
			
			  

 </script>
 </head>

<body>
<form name="form3" method="post" action="<?php echo MAIN_URL;?>index.php/loginsuccess/insertstudent">
  <div style="height: 40px; width:10px">
           <label id="emailError" style="display:none; color:red; font-size: 12px;" class="error">Email id not valid
           </label>
           </div>

		    <div style="height: 40px; width:10px">
           <label id="courseError" style="display:none; color:red; font-size: 12px;" class="error">Select Course
           </label>
           </div>
  
   <label>Student Name</label>
          <input type="text" name="stuname" id="stuname" class="common">
           <label>Contact Number</label>
		    
          <input type="text" name="cnumber" id="cnumber" class="common">
		  <label>Email id</label>
		    
          <input type="text" name="emailid" id="emailid" class="common">
		  <label>Address</label>
		    
          <input type="text" name="address" id="address" class="common">
		  <label>Course</label>

		    
<div style="height: 30px; margin-top: 300px;">
<select align= "right" class="input" name="course_combo" id="course_combo">
 
<option value="-1" selected> 
<?php
 
if($course_details!=""){
 
echo "--Select Course--";
foreach ($course_details->result() as $row)
            {
	 print("<option value=\"{$row->id}\">{$row->courseName}</option>");
echo"<br>";
      }}
?>
	  </option>
	  </select>  </div>
		  
           <label>Password</label>
		    
          <input type="text" name="password" id="password" >
  
             <input value="Clear" type="reset" id="r_button">
		  <input value="Submit" type="submit" id="s_button">
 
 
              <?php
               if($this->session->flashdata('student_response'))
                  {
      echo "<label class='error' style='float: left; margin-top: 12px;width: 191px; font-size: 16px; color: #04739D;'>
       Student Record Inserted..</label>";
	              unset($_SESSION['student_response']);
	  
                   }?>
   
  
 
</form>
</body>
</html>
                   